part of '../../repository.dart';

const _kGooglePlayPurchasedSubscriptionCancellationSurveyReasonKey = 'reason';
const _kGooglePlayPurchasedSubscriptionCancellationSurveyCustomAnswerKey = 'custom_answer';

class _GooglePlayPurchasedSubscriptionCancellationSurveyResultDto extends Equatable {
  const _GooglePlayPurchasedSubscriptionCancellationSurveyResultDto._internal({
    required this.reasonDto,
    required this.customAnswer,
  });

  final _GooglePlayPurchasedSubscriptionCancellationSurveyReasonDto reasonDto;
  final String? customAnswer;

  @override
  List<Object?> get props {
    return [
      reasonDto,
      customAnswer,
    ];
  }

  factory _GooglePlayPurchasedSubscriptionCancellationSurveyResultDto.fromJson(
      Map<String, dynamic> json) {
    final reasonString =
        json[_kGooglePlayPurchasedSubscriptionCancellationSurveyReasonKey] as String;
    final reasonDto =
        _GooglePlayPurchasedSubscriptionCancellationSurveyReasonDto.fromString(reasonString);

    return _GooglePlayPurchasedSubscriptionCancellationSurveyResultDto._internal(
      reasonDto: reasonDto,
      customAnswer: json[_kGooglePlayPurchasedSubscriptionCancellationSurveyCustomAnswerKey],
    );
  }

  GooglePlayPurchasedSubscriptionCancellationSurveyResult toEntity() {
    return GooglePlayPurchasedSubscriptionCancellationSurveyResult(
      reason: reasonDto.toEntity(),
      customAnswer: customAnswer,
    );
  }
}
